package itcast.web.servlet;

import itcast.domain.Buildmanager;
import itcast.service.BuildmanagerService;
import itcast.service.impl.BuildmanagerServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/buildmanagerServlet")
public class BuildmanagerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1.调用BuildmanagerService完成查询
        BuildmanagerService buildmanagerService=new BuildmanagerServiceimpl();
        List<Buildmanager> buildmanagers=buildmanagerService.findAll();
        //2.将list存入request域
        request.setAttribute("buildmanagers",buildmanagers);
        //3.转发到Build management.jsp
       request.getRequestDispatcher("/systemadmin/Building-management.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }
}
